package ch15;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 * Created by 春旺 on 2017/10/16.
 */
public class CircularArrayQueueTest {
    CircularArrayQueue queue = new CircularArrayQueue();
    @Test
    public void dequeue() throws Exception {
        queue.enqueue(1);
        assertEquals(1,queue.size());
        assertEquals(1,queue.dequeue());
        assertEquals(0,queue.size());
        queue.enqueue("chun");
        queue.enqueue("wang");
        assertEquals("chun",queue.dequeue());
    }

    @Test
    public void first() throws Exception {
        CircularArrayQueue queue2 = new CircularArrayQueue();
        queue2.enqueue("hhh");
        queue2.enqueue("ooo");
        assertEquals("hhh",queue2.first());
    }

    @Test
    public void isEmpty() throws Exception {
        assertEquals(true,queue.isEmpty());
        queue.enqueue("打代码");
        assertEquals(false,queue.isEmpty());
    }

    @Test
    public void size() throws Exception {
        assertEquals(0,queue.size());
        for (int i = 0;i< 200;i++){
            queue.enqueue(i);
        }
        assertEquals(200,queue.size());
    }
    @Test
    public void testToString() throws Exception {
//TODO: Test goes here...
        queue.enqueue("20162324");
        queue.enqueue("春");
        queue.enqueue("旺");
        assertEquals("20162324春旺",queue.toString());
        queue.dequeue();
        assertEquals("春旺",queue.toString());
    }


}

